-
-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x] RLS without central user (role) having bypassrls #1288
base: master
Are you sure you want to change the base?
[4.x] RLS without central user (role) having bypassrls #1288
Conversation
…-bypassrls' into rls-fix-for-central-user-without-bypassrls
Thanks for the PR! Can you revert the formatting changes? |
Ah nevermind, I see that there's an extra loop now. |
Currently in the process of testing an alternative implementation for this btw, so no need to bother fixing phpstan for now. |
Could you provide some concrete reproduction steps for the bug first? |
The user that is used as the central user in tenancy should not have the Could you try with:
Or just create a new user:
Some possible steps to follow:
Without this pull request the app will throw a error or just not select the data, because the user cannot access the data without rls bypass. You can check the policies by running |
Thanks, we managed to reproduce the issue with those steps. I have a few questions though:
|
Original issue
Description
I am using a managed Postgres solution where the admin role does not have and can not get BYPASSRLS.
That leads to the behaviour that when using the 'central connection' i don't have access to tenant data (including 'tennant_user').
That makes the management of tenants impossible.
So I thought of a solution giving the tenancy.rls.user.username (database tenant_user) the rsl policies already implemented by the package.
AND giving the central user a policy with full access:
This worked for me :)
Why this should be added
I have implemented this in the
CreateUserWithRLSPolicies
command and 'TableRLSManager' class.This could use some more refactoring and possibly detecting if central user has BYPASSRLS permissions and ommiting the central policy.
But this is to give you an idea of what I did with this.
What do you think?
Original @stancl reply: